
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>框架模型api · Restack-Mobile</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="mobiscroll/INTRODUCE.html" />
    
    
    <link rel="prev" href="AppConfig.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="" target="_blank" class="custom-link">Restack-Mobile</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    RESTACK套件简介
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">SDK使用</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="INSTALLATION.html">
            
                <a href="INSTALLATION.html">
            
                    
                    SDK安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="CREATE_PROJ.html">
            
                <a href="CREATE_PROJ.html">
            
                    
                    创建项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="Production.html">
            
                <a href="Production.html">
            
                    
                    生产环境运行
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="Development.html">
            
                <a href="Development.html">
            
                    
                    开发环境运行
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">SDK详细说明</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="Menu.html">
            
                <a href="Menu.html">
            
                    
                    推荐目录结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="ConfigIntro.html">
            
                <a href="ConfigIntro.html">
            
                    
                    项目配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="CONFIG_INFO.html">
            
                <a href="CONFIG_INFO.html">
            
                    
                    SDK默认配置一览
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">restack-core开发文档</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="Frame.html">
            
                <a href="Frame.html">
            
                    
                    框架组成
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="WHYUS.html">
            
                <a href="WHYUS.html">
            
                    
                    Why us?
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="FastBuid.html">
            
                <a href="FastBuid.html">
            
                    
                    快速开发指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="AppConfig.html">
            
                <a href="AppConfig.html">
            
                    
                    框架初始化配置
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="4.5" data-path="MODEL.html">
            
                <a href="MODEL.html">
            
                    
                    框架模型api
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">mobiscroll组件文档</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="mobiscroll/INTRODUCE.html">
            
                <a href="mobiscroll/INTRODUCE.html">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="mobiscroll/Calendar.html">
            
                <a href="mobiscroll/Calendar.html">
            
                    
                    Calendar
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="mobiscroll/Event Calendar.html">
            
                <a href="mobiscroll/Event Calendar.html">
            
                    
                    Event Calendar
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="mobiscroll/Color.html">
            
                <a href="mobiscroll/Color.html">
            
                    
                    Color
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="mobiscroll/Date&Time.html">
            
                <a href="mobiscroll/Date&Time.html">
            
                    
                    Date&Time
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="mobiscroll/Form_Button.html">
            
                <a href="mobiscroll/Form_Button.html">
            
                    
                    Button
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="mobiscroll/Form_Checkbox.html">
            
                <a href="mobiscroll/Form_Checkbox.html">
            
                    
                    Checkbox
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="mobiscroll/Form_Progress.html">
            
                <a href="mobiscroll/Form_Progress.html">
            
                    
                    Progress
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.9" data-path="mobiscroll/Form_Radiobuttons.html">
            
                <a href="mobiscroll/Form_Radiobuttons.html">
            
                    
                    RadioButton
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.10" data-path="mobiscroll/Form_Select.html">
            
                <a href="mobiscroll/Form_Select.html">
            
                    
                    Form_Select
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.11" data-path="mobiscroll/Form_Stepper.html">
            
                <a href="mobiscroll/Form_Stepper.html">
            
                    
                    Stepper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.12" data-path="mobiscroll/Form_Switch.html">
            
                <a href="mobiscroll/Form_Switch.html">
            
                    
                    Switch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.13" data-path="mobiscroll/Form_Textfields.html">
            
                <a href="mobiscroll/Form_Textfields.html">
            
                    
                    TextField
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.14" data-path="mobiscroll/Forms_slider.html">
            
                <a href="mobiscroll/Forms_slider.html">
            
                    
                    Slider
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.15" data-path="mobiscroll/Form_DateSilder.html">
            
                <a href="mobiscroll/Form_DateSilder.html">
            
                    
                    DateSlider
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.16" data-path="mobiscroll/FormsSegmented.html">
            
                <a href="mobiscroll/FormsSegmented.html">
            
                    
                    Segmented
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.17" data-path="mobiscroll/Image.html">
            
                <a href="mobiscroll/Image.html">
            
                    
                    Image
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.18" data-path="mobiscroll/ListView.html">
            
                <a href="mobiscroll/ListView.html">
            
                    
                    ListView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.19" data-path="mobiscroll/Measurement.html">
            
                <a href="mobiscroll/Measurement.html">
            
                    
                    Measurement
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.20" data-path="mobiscroll/MenuStrip.html">
            
                <a href="mobiscroll/MenuStrip.html">
            
                    
                    MenuStrip
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.21" data-path="mobiscroll/Number.html">
            
                <a href="mobiscroll/Number.html">
            
                    
                    Number
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.22" data-path="mobiscroll/Numpad.html">
            
                <a href="mobiscroll/Numpad.html">
            
                    
                    Numpad
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.23" data-path="mobiscroll/Range.html">
            
                <a href="mobiscroll/Range.html">
            
                    
                    Range
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.24" data-path="mobiscroll/Rating.html">
            
                <a href="mobiscroll/Rating.html">
            
                    
                    Rating
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.25" data-path="mobiscroll/Scroller.html">
            
                <a href="mobiscroll/Scroller.html">
            
                    
                    Scroller
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.26" data-path="mobiscroll/Select.html">
            
                <a href="mobiscroll/Select.html">
            
                    
                    Select
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.27" data-path="mobiscroll/Timer.html">
            
                <a href="mobiscroll/Timer.html">
            
                    
                    Timer
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.28" data-path="mobiscroll/Timespan.html">
            
                <a href="mobiscroll/Timespan.html">
            
                    
                    Timespan
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.29" data-path="mobiscroll/Treelist.html">
            
                <a href="mobiscroll/Treelist.html">
            
                    
                    Treelist
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.30" data-path="mobiscroll/Widget.html">
            
                <a href="mobiscroll/Widget.html">
            
                    
                    Widget
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >框架模型api</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x6846;&#x67B6;&#x6A21;&#x578B;api">&#x6846;&#x67B6;&#x6A21;&#x578B;api</h1>
<h4 id="&#x7B80;&#x4ECB;">&#x7B80;&#x4ECB;</h4>
<p><code>restack-core model</code> &#x662F;&#x57FA;&#x4E8E;<code>redux</code>, <code>saga</code>&#x8FDB;&#x884C;&#x518D;&#x5C01;&#x88C5;, &#x4F7F;&#x7528;generator&#x4F5C;&#x4E3A;&#x6838;&#x5FC3;&#x9A71;&#x52A8;&#x7684;&#x72B6;&#x6001;&#x53D8;&#x66F4;&#x6A21;&#x578B;, &#x4F7F;&#x7528;<code>restack-core</code>&#x8FDB;&#x884C;&#x5F00;&#x53D1;&#x65F6;&#x4E0D;&#x9700;&#x8981;&#x5904;&#x7406;&#x4F17;&#x591A;<code>reducer&amp;action</code>. &#x53EA;&#x9700;&#x8981;&#x5173;&#x6CE8;<code>restack-core model</code>&#x5373;&#x53EF;.</p>
<h4 id="&#x6587;&#x4EF6;&#x547D;&#x540D;">&#x6587;&#x4EF6;&#x547D;&#x540D;</h4>
<p>&#x4E3A;&#x4E86;&#x5F00;&#x53D1;&#x8005;&#x7B80;&#x4FBF;&#x5FEB;&#x6377;&#x5730;&#x4F7F;&#x7528;,<code>restack-core model</code> &#x53EF;&#x4EE5;&#x91C7;&#x7528;&#x547D;&#x540D;&#x89C4;&#x8303;&#x5BFC;&#x5165;&#x65B9;&#x5F0F;&#x8FDB;&#x884C;&#x52A0;&#x8F7D;, &#x5F00;&#x53D1;&#x8005;&#x4E0D;&#x9700;&#x8981;&#x7EF4;&#x62A4;&#x5E9E;&#x5927;&#x7684;reducer&#x7BA1;&#x7406;&#x6587;&#x4EF6;, &#x6A21;&#x578B;&#x6587;&#x4EF6;&#x547D;&#x540D;&#x7B26;&#x5408;<code>&#x6587;&#x4EF6;&#x540D;.model.js</code> &#x7684;&#x89C4;&#x5219;, &#x6846;&#x67B6;&#x5373;&#x4F1A;&#x81EA;&#x52A8;&#x8BC6;&#x522B;&#x5BFC;&#x5165;.</p>
<h4 id="&#x6A21;&#x578B;&#x4EE3;&#x7801;&#x7ED3;&#x6784;">&#x6A21;&#x578B;&#x4EE3;&#x7801;&#x7ED3;&#x6784;</h4>
<p>&#x4EE5;&#x4E0B;&#x662F;&#x6A21;&#x578B;&#x7684;&#x4EE3;&#x7801;&#x7ED3;&#x6784;:</p>
<pre><code>{
  name: &apos;example&apos;,  
  initialState: {   
    isFetching: false,
  },
  sagas: {    
    *fetch() {
      yield console.log(&quot;fetching list&quot;);
    },
  }
}
</code></pre><p><code>name</code> &#x5BF9;&#x5E94;reducer&#x540D;&#x79F0;, &#x5728;&#x9875;&#x9762;&#x94FE;&#x63A5;redux&#x540E;&#x6839;&#x636E;&#x6B64;&#x547D;&#x540D;&#x83B7;&#x53D6;&#x72B6;&#x6001;.</p>
<p><code>initialState</code> reducer&#x521D;&#x59CB;&#x5316;&#x72B6;&#x6001;, &#x5728;&#x672A;&#x8FDB;&#x884C;&#x72B6;&#x6001;&#x66F4;&#x65B0;&#x65F6;, reducer&#x7684;&#x9ED8;&#x8BA4;&#x72B6;&#x6001;.</p>
<p><code>sagas</code> &#x5BF9;&#x5E94;&#x7684;&#x662F;<code>redux-saga</code>&#x7684;generator function. <code>redux-saga&#x5B98;&#x65B9;&#x6587;&#x6863;</code><a href="https://github.com/yelouafi/redux-saga" target="_blank">https://github.com/yelouafi/redux-saga</a>.</p>
<h4 id="&#x9875;&#x9762;&#x8C03;&#x7528;">&#x9875;&#x9762;&#x8C03;&#x7528;</h4>
<p>&#x9875;&#x9762;&#x8C03;&#x7528;<code>restack-core model</code>&#x53D1;&#x8D77;&#x72B6;&#x6001;&#x53D8;&#x66F4;/&#x8BF7;&#x6C42;.</p>
<ol>
<li>&#x4F7F;&#x7528;<code>react-redux</code>&#x7684;<code>connect</code>&#x5173;&#x8054;redux&#x5230;&#x9875;&#x9762;&#x4E2D;<pre><code>@connect(
  state =&gt; {
        return {
            example: state.example
        }
    }
)
export default class Example extends Component {
...
}
</code></pre></li>
<li><p>&#x5728;&#x9875;&#x9762;&#x4E2D;&#x8C03;&#x7528;dispatch&#x65B9;&#x6CD5;&#x53D1;&#x8D77;&#x4E00;&#x4E2A;&#x53D8;&#x66F4;.&#x82E5;&#x8981;&#x4F20;&#x9012;&#x53C2;&#x6570;&#x901A;&#x8FC7;</p>
<pre><code>export default class Example extends Component {

  componentDidMount(){
    this.props.dispatch({
      type:&quot;example/fetch&quot;,
      payload: {
          isFetching: true,
      }
    })
  }
}
</code></pre><p><code>type</code> &#x4F5C;&#x4E3A;&#x5339;&#x914D;model&#x7684;&#x53C2;&#x6570;,&#x547D;&#x540D;&#x89C4;&#x5219;&#x662F; <code>model&#x914D;&#x7F6E;&#x7684;name/saga&#x4E0B;&#x7684;function&#x540D;&#x79F0;</code>&#x8FD9;&#x6837;&#x65E2;&#x53EF;&#x6307;&#x5B9A;&#x5524;&#x8D77;&#x54EA;&#x4E2A;&#x65B9;&#x6CD5;.
<code>payload</code> &#x5982;&#x82E5;&#x6709;&#x53C2;&#x6570;&#x4F20;&#x9012;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8BE5;&#x53C2;&#x6570;&#x4F20;&#x5230;sagas&#x7684;function&#x4E0B;. sagas&#x7684;function&#x53EF;&#x83B7;&#x53D6;&#x53C2;&#x6570;&#x5982;&#x4E0B;:</p>
<pre><code>sagas: {    
  *fetch(action, {update, put, call }) { //saga&#x7684;effects
      yield console.log(&quot;fetching list&quot;);
      yield update({isFetching: action.payload.isFetching})
      const response = yield call(fetch, `/api/some/module`) //&#x8FDB;&#x884C;&#x8BF7;&#x6C42;
      if (response) {  //&#x6210;&#x529F;
        yield put({type: &quot;exampleModules.SUCCESS&quot;, response});
      } else { //&#x5931;&#x8D25;
        yield put({type: &quot;exampleModules.FAILURE&quot;, error})
      }
  },
}
</code></pre></li>
<li><p>&#x53D6;&#x5F97;&#x7ED3;&#x679C;&#x540E;,&#x9875;&#x9762;&#x8FDB;&#x884C;&#x53D6;&#x503C;/&#x72B6;&#x6001;&#x66F4;&#x65B0;</p>
<pre><code>export default class Example extends Component {
 componentDidMount(){
   this.props.dispatch({
     type:&quot;example/fetch&quot;,
     payload: {
         isFetching: true,
     }
   })
 }
 render(){
   return (
     &lt;div&gt;
       {this.props.example.isFetching? &quot;fetching now&quot;: &quot;done!&quot;}
     &lt;/div&gt;
   )
 }
}
</code></pre></li>
</ol>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="AppConfig.html" class="navigation navigation-prev " aria-label="Previous page: 框架初始化配置">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="mobiscroll/INTRODUCE.html" class="navigation navigation-next " aria-label="Next page: 简介">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"框架模型api","level":"4.5","depth":1,"next":{"title":"简介","level":"5.1","depth":1,"path":"mobiscroll/INTRODUCE.md","ref":"mobiscroll/INTRODUCE.md","articles":[]},"previous":{"title":"框架初始化配置","level":"4.4","depth":1,"path":"AppConfig.md","ref":"AppConfig.md","articles":[]},"dir":"ltr"},"config":{"plugins":["theme-comscore","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"livereload":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"theme-comscore":{},"theme-api":{"languages":[{"lang":"js","name":"JavaScript","default":true}]},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageBreaksBefore":"/","headerTemplate":null,"paperSize":"a4","margin":{"right":62,"left":62,"top":36,"bottom":36},"fontSize":12,"fontFamily":"Arial","footerTemplate":null,"chapterMark":"pagebreak","pageNumbers":false},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"isbn":"","variables":{},"title":"Restack-Mobile","links":{"sharing":{"all":null,"facebook":null,"google":null,"twitter":null,"weibo":null},"sidebar":{"Restack-Mobile":""}},"gitbook":"*","description":null,"extension":null},"file":{"path":"MODEL.md","mtime":"2016-11-28T09:45:22.000Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2016-12-08T04:17:17.070Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

